home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / fssock13 / demo / fstest / client.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-08-23  |  11.3 KB  |  398 lines

  1. VERSION 2.00
  2. Begin Form client 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Client Test"
  6.    ClientHeight    =   6240
  7.    ClientLeft      =   585
  8.    ClientTop       =   1620
  9.    ClientWidth     =   6960
  10.    Height          =   6645
  11.    Icon            =   CLIENT.FRX:0000
  12.    KeyPreview      =   -1  'True
  13.    Left            =   525
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   6240
  16.    ScaleWidth      =   6960
  17.    Top             =   1275
  18.    Width           =   7080
  19.    Begin TextBox localport 
  20.       Height          =   285
  21.       Left            =   120
  22.       TabIndex        =   22
  23.       Top             =   4920
  24.       Width           =   2175
  25.    End
  26.    Begin TextBox localaddress 
  27.       Height          =   285
  28.       Left            =   120
  29.       TabIndex        =   21
  30.       Top             =   4320
  31.       Width           =   2175
  32.    End
  33.    Begin FSSocket FSSocket1 
  34.       Connect         =   0   'False
  35.       EOL             =   ""
  36.       HostAddress     =   ""
  37.       HostName        =   ""
  38.       InputBufferSize =   4096
  39.       Left            =   1800
  40.       Listen          =   0   'False
  41.       ListenPort      =   0
  42.       OutputBufferSize=   4096
  43.       PortNumber      =   0
  44.       Protocol        =   0  'TCP
  45.       ServiceName     =   ""
  46.       Top             =   1080
  47.    End
  48.    Begin CommandButton Command4 
  49.       Caption         =   "Set"
  50.       Height          =   255
  51.       Left            =   1800
  52.       TabIndex        =   6
  53.       Top             =   2520
  54.       Width           =   495
  55.    End
  56.    Begin CommandButton Command3 
  57.       Caption         =   "Set"
  58.       Height          =   255
  59.       Left            =   1800
  60.       TabIndex        =   4
  61.       Top             =   1920
  62.       Width           =   495
  63.    End
  64.    Begin CommandButton Command2 
  65.       Caption         =   "Disconnect"
  66.       Enabled         =   0   'False
  67.       Height          =   375
  68.       Left            =   1080
  69.       TabIndex        =   10
  70.       Top             =   5760
  71.       Width           =   1215
  72.    End
  73.    Begin TextBox SVSNAM 
  74.       Height          =   285
  75.       Left            =   120
  76.       TabIndex        =   8
  77.       Top             =   3720
  78.       Width           =   2175
  79.    End
  80.    Begin TextBox PORTNUM 
  81.       Height          =   285
  82.       Left            =   120
  83.       TabIndex        =   7
  84.       Top             =   3120
  85.       Width           =   2175
  86.    End
  87.    Begin TextBox HSTADDR 
  88.       Height          =   285
  89.       Left            =   120
  90.       TabIndex        =   5
  91.       Top             =   2520
  92.       Width           =   1575
  93.    End
  94.    Begin OptionButton TCP 
  95.       BackColor       =   &H00C0C0C0&
  96.       Caption         =   "TCP"
  97.       Height          =   255
  98.       Left            =   120
  99.       TabIndex        =   1
  100.       Top             =   960
  101.       Value           =   -1  'True
  102.       Width           =   1095
  103.    End
  104.    Begin OptionButton UDP 
  105.       BackColor       =   &H00C0C0C0&
  106.       Caption         =   "UDP"
  107.       Height          =   255
  108.       Left            =   120
  109.       TabIndex        =   2
  110.       Top             =   1320
  111.       Width           =   1095
  112.    End
  113.    Begin TextBox HSTNAM 
  114.       Height          =   285
  115.       Left            =   120
  116.       TabIndex        =   3
  117.       Top             =   1920
  118.       Width           =   1575
  119.    End
  120.    Begin CheckBox RDYTOSND 
  121.       BackColor       =   &H00C0C0C0&
  122.       Caption         =   "Ready to Send"
  123.       Height          =   255
  124.       Left            =   120
  125.       TabIndex        =   14
  126.       TabStop         =   0   'False
  127.       Top             =   120
  128.       Width           =   1695
  129.    End
  130.    Begin CheckBox CNTD 
  131.       BackColor       =   &H00C0C0C0&
  132.       Caption         =   "Connected"
  133.       Height          =   255
  134.       Left            =   120
  135.       TabIndex        =   13
  136.       TabStop         =   0   'False
  137.       Top             =   480
  138.       Width           =   1455
  139.    End
  140.    Begin CommandButton Command1 
  141.       Caption         =   "Connect"
  142.       Height          =   375
  143.       Left            =   1080
  144.       TabIndex        =   9
  145.       Top             =   5400
  146.       Width           =   1215
  147.    End
  148.    Begin TextBox OUTDATA 
  149.       Height          =   285
  150.       Left            =   3120
  151.       TabIndex        =   0
  152.       Text            =   "Text2"
  153.       Top             =   5880
  154.       Width           =   3735
  155.    End
  156.    Begin TextBox INDATA 
  157.       FontBold        =   -1  'True
  158.       FontItalic      =   0   'False
  159.       FontName        =   "Courier New"
  160.       FontSize        =   8.25
  161.       FontStrikethru  =   0   'False
  162.       FontUnderline   =   0   'False
  163.       Height          =   5775
  164.       Left            =   2400
  165.       MultiLine       =   -1  'True
  166.       ScrollBars      =   3  'Both
  167.       TabIndex        =   11
  168.       TabStop         =   0   'False
  169.       Text            =   "Text1"
  170.       Top             =   0
  171.       Width           =   4575
  172.    End
  173.    Begin Label Label7 
  174.       AutoSize        =   -1  'True
  175.       BackStyle       =   0  'Transparent
  176.       Caption         =   "Local Port"
  177.       Height          =   195
  178.       Left            =   120
  179.       TabIndex        =   20
  180.       Top             =   4680
  181.       Width           =   885
  182.    End
  183.    Begin Label Label6 
  184.       AutoSize        =   -1  'True
  185.       BackStyle       =   0  'Transparent
  186.       Caption         =   "Local Address"
  187.       Height          =   195
  188.       Left            =   120
  189.       TabIndex        =   19
  190.       Top             =   4080
  191.       Width           =   1215
  192.    End
  193.    Begin Label Label5 
  194.       AutoSize        =   -1  'True
  195.       BackStyle       =   0  'Transparent
  196.       Caption         =   "Service"
  197.       Height          =   195
  198.       Left            =   120
  199.       TabIndex        =   18
  200.       Top             =   3480
  201.       Width           =   660
  202.    End
  203.    Begin Label Label4 
  204.       AutoSize        =   -1  'True
  205.       BackStyle       =   0  'Transparent
  206.       Caption         =   "Port"
  207.       Height          =   195
  208.       Left            =   120
  209.       TabIndex        =   17
  210.       Top             =   2880
  211.       Width           =   360
  212.    End
  213.    Begin Line Line2 
  214.       X1              =   2400
  215.       X2              =   2400
  216.       Y1              =   0
  217.       Y2              =   6240
  218.    End
  219.    Begin Line Line1 
  220.       X1              =   0
  221.       X2              =   2400
  222.       Y1              =   840
  223.       Y2              =   840
  224.    End
  225.    Begin Label Label3 
  226.       AutoSize        =   -1  'True
  227.       BackStyle       =   0  'Transparent
  228.       Caption         =   "HostAddress"
  229.       Height          =   195
  230.       Left            =   120
  231.       TabIndex        =   16
  232.       Top             =   2280
  233.       Width           =   1080
  234.    End
  235.    Begin Label Label2 
  236.       AutoSize        =   -1  'True
  237.       BackStyle       =   0  'Transparent
  238.       Caption         =   "HostName"
  239.       Height          =   195
  240.       Left            =   120
  241.       TabIndex        =   15
  242.       Top             =   1680
  243.       Width           =   885
  244.    End
  245.    Begin Label Label1 
  246.       Alignment       =   1  'Right Justify
  247.       AutoSize        =   -1  'True
  248.       BackStyle       =   0  'Transparent
  249.       Caption         =   "Input:"
  250.       Height          =   255
  251.       Left            =   2520
  252.       TabIndex        =   12
  253.       Top             =   5880
  254.       Width           =   510
  255.    End
  256. Dim lastchanged As Integer
  257. Sub Command1_Click ()
  258.     fssocket1.EOL = Chr$(10)
  259.     On Error GoTo errx
  260.     fssocket1.Connect = True
  261.     LocalAddress.Text = fssocket1.LocalAddress
  262.     LocalPort.Text = fssocket1.LocalPort
  263.     If fssocket1.Protocol = 1 Then
  264.         command2.Enabled = True
  265.         command1.Enabled = False
  266.     End If
  267.     Exit Sub
  268. errx:
  269.     MsgBox fssocket1.WSALastErrorMsg
  270.     Resume Next
  271. End Sub
  272. Sub Command2_Click ()
  273.     fssocket1.Connect = False
  274.     LocalAddress.Text = ""
  275.     LocalPort.Text = ""
  276. End Sub
  277. Sub Command3_Click ()
  278.         On Error Resume Next
  279.         fssocket1.HostName = HSTNAM.Text
  280.         hstaddr.Text = fssocket1.HostAddress
  281. End Sub
  282. Sub Command4_Click ()
  283. On Error Resume Next
  284.         fssocket1.HostAddress = hstaddr.Text
  285.         HSTNAM.Text = fssocket1.HostName
  286. End Sub
  287. Sub Command5_Click ()
  288.     fssocket1.Send = String$(5000, Asc("B") - 1) & Chr$(10)
  289. End Sub
  290. Sub Form_Load ()
  291.     fssocket1.EOL = Chr$(10)
  292.     INDATA.Text = ""
  293.     OUTDATA.Text = ""
  294.     HSTNAM.Text = fssocket1.HostName
  295.     hstaddr.Text = fssocket1.HostAddress
  296.     PORTNUM.Text = fssocket1.PortNumber
  297.     SVSNAM.Text = fssocket1.ServiceName
  298.     LocalAddress.Text = fssocket1.LocalAddress
  299.     LocalPort.Text = fssocket1.LocalPort
  300.     If fssocket1.Protocol = 0 Then
  301.         TCP.Value = True
  302.     Else
  303.         UDP.Value = True
  304.     End If
  305.     Load server
  306.     lastchanged = 0
  307. End Sub
  308. Sub Form_Unload (Cancel As Integer)
  309.     Unload server
  310. End Sub
  311. Sub FSSocket1_Connected (StatusCode As Integer, description As String)
  312.     CNTD.Value = 1
  313.     RDYTOSND.Value = 1
  314.     command1.Enabled = False
  315.     command2.Enabled = True
  316.     LocalAddress.Text = fssocket1.LocalAddress
  317.     LocalPort.Text = fssocket1.LocalPort
  318. End Sub
  319. Sub FSSocket1_DataReceived (Text As String, EOL As Integer)
  320. Static fulstrng As String
  321.     fulstrng = fulstrng + Text
  322.     If EOL Then
  323.         INDATA.SelStart = 32000
  324.         INDATA.SelText = fulstrng & Chr$(13) & Chr$(10)
  325.         fulstrng = ""
  326.     End If
  327. End Sub
  328. Sub FSSocket1_Disconnected (StatusCode As Integer, description As String)
  329.     CNTD.Value = 0
  330.     RDYTOSND.Value = 0
  331.     command1.Enabled = True
  332.     command2.Enabled = False
  333.     LocalAddress.Text = fssocket1.LocalAddress
  334.     LocalPort.Text = fssocket1.LocalPort
  335. End Sub
  336. Sub FSSocket1_ReadyToSend ()
  337.     RDYTOSND.Value = 1
  338.     Debug.Print "readtosend"
  339. End Sub
  340. Sub HSTADDR_KeyPress (keyascii As Integer)
  341. On Error Resume Next
  342.     If keyascii = 13 Then
  343.         fssocket1.HostAddress = hstaddr.Text
  344.         HSTNAM.Text = fssocket1.HostName
  345.         keyascii = 0
  346.     End If
  347. End Sub
  348. Sub HSTNAM_KeyPress (keyascii As Integer)
  349.     On Error Resume Next
  350.     If keyascii = 13 Then
  351.         fssocket1.HostName = HSTNAM.Text
  352.         hstaddr.Text = fssocket1.HostAddress
  353.         keyascii = 0
  354.     End If
  355. End Sub
  356. Sub OUTDATA_KeyPress (keyascii As Integer)
  357. On Error GoTo cantsend
  358. Dim x As Integer
  359.     If keyascii = 13 Then
  360.         If fssocket1.Connect = True Then
  361.             If fssocket1.Protocol = 1 Then
  362.                 fssocket1.HostAddress = hstaddr.Text
  363.             End If
  364.             fssocket1.Send = OUTDATA.Text & Chr$(10)
  365.         End If
  366.         OUTDATA.Text = ""
  367.         keyascii = 0
  368.     End If
  369. Exit Sub
  370. cantsend:
  371.     If fssocket1.WSALastError = 10035 Then
  372.         RDYTOSND.Value = 0
  373.         While RDYTOSND.Value = 0
  374.             DoEvents
  375.         Wend
  376.     Else
  377.         MsgBox fssocket1.WSALastErrorMsg
  378.         Exit Sub
  379.     End If
  380.     Resume
  381. End Sub
  382. Sub PORTNUM_Change ()
  383. On Error Resume Next
  384.         fssocket1.PortNumber = PORTNUM.Text
  385.         SVSNAM.Text = fssocket1.ServiceName
  386. End Sub
  387. Sub SVSNAM_Change ()
  388. On Error Resume Next
  389.         fssocket1.ServiceName = SVSNAM.Text
  390.         PORTNUM.Text = fssocket1.PortNumber
  391. End Sub
  392. Sub TCP_Click ()
  393.     fssocket1.Protocol = 0
  394. End Sub
  395. Sub UDP_Click ()
  396.     fssocket1.Protocol = 1
  397. End Sub
  398.